package com.walle.eve.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;

@Mapper
@CacheConfig(cacheNames = "users")
public interface UserMapper {

	@Cacheable
	@Select("select n_id,c_user_name,c_real_name from t_sys_user where n_id=#{id}")
	Map<String, Object> getUserInfoById(String id);

	@Select("select n_id,c_user_name,c_real_name from t_sys_user")
	List<Map<String, Object>> getUserList();

	@Insert("insert into t_sys_user(c_user_name,c_real_name,c_password) values(#{userName},#{realName},'e10adc3949ba59abbe56e057f20f883e')")
	int addUser(@Param(value = "userName") String userName, @Param(value = "realName") String realName);

	@CacheEvict
	@Delete("delete from t_sys_user where n_id=#{id}")
	int deleteUser(String id);

}
